<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>
  
  <div class="container-fluid ms-container has-ms-sidemenu">
    
    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">角色管理&nbsp;&nbsp;-&nbsp;&nbsp;设置权限范围</li>
    </ol>
    
    <div class="ms-content-layout">
    
       <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/roles" data-validate="true">
          
         <div class="block-heading">
           <h5>基本信息</h5>
         </div>
          
         <div class="form-group ms-form-group">
           <label class="col-xs-2 control-label">标识:</label>
           <div class="col-xs-3">
             <p class="form-control-static">${roleCode}</p>
             <input type="hidden" name="code" value="${roleCode}">
           </div>
           
           <label class="col-xs-2 control-label">所属模板:</label>
           <div class="col-xs-3">
             <p class="form-control-static">${roleTemplate.name}</p>
             <input type="hidden" name="template" value="${roleTemplate}">
           </div>
         </div>
         
         <div class="form-group ms-form-group">
           <label class="col-xs-2 control-label"><span class="text-red">*</span>名称:</label>
           <div class="col-xs-3">
             <input type="text" name="name" placeholder="名称" class="form-control" data-validate="required" autocomplete="off" tabindex="1">
           </div>
          <label class="col-xs-2 control-label"><span class="text-red">*</span>描述:</label>
          <div class="col-xs-3">
            <input type="text" name="description" placeholder="描述" class="form-control" data-validate="required" autocomplete="off" tabindex="2">
           </div>
         </div>
          
          
         <div class="row" style="margin-top: 50px;">
         
           <!-------BEGIN 菜单权限  ------->
           <div class="col-xs-12 resource-panel clearfix">
             <div class="block-heading">
               <h5>菜单权限</h5>
             </div>
             
               <c:forEach items="${secure.menus}" var="menu">
                
                  <c:if test="${menuNames.contains(menu.id)}">
                    
                    <div class="col-xs-6">
                    
                      <div class="panel panel-default role-resource">
                        
                        <div class="panel-heading checkbox">
                          <label style="padding-left: 12px; line-height: 20px;">
                            <input type="checkbox" id="${menu.id}" value="${menu.id}" name="menus" style="margin: 5px 0 0 -19px;" checked>${menu.name}
                          </label>
                        </div>
                        
                        <div class="role-submenu-table">
                          
                          <table class="table" id="${menu.id}-table">
                            <thead>
                              <tr>
                                <th style="width:20px; text-align: center"></th>
                                <th>名称</th>
                                <th>描述</th>
                              </tr>
                            </thead>
                            <tbody>
                              
                            <!-- BEGIN 二级菜单 -->
                            <c:forEach var="submenu" items="${secure.submenus[menu.id]}">
                              
                              <c:if test="${submenuNames.contains(submenu.id)}">
                              
                                <tr class="submenu-hidden">
                                  <td class="text-center">&nbsp;-&nbsp;<input class="${submenu.id}" type="checkbox" name="menus" value="${submenu.id}" style="display:none" checked></td>
                                  <td>${submenu.name}</td>
                                  <td>${submenu.id}</td>
                                </tr>
                                
                                <!-- BEGIN 三级菜单 -->
                                <c:forEach items="${submenu.submenus}" var="leafmenu">
                                  <c:if test="${submenuNames.contains(leafmenu.id)}">
                                    <tr>
                                      <td class="text-center"><input class="${submenu.id}-leafmenu" type="checkbox" name="menus" value="${leafmenu.id}" checked></td>
                                      <td>${leafmenu.name}</td>
                                      <td>${leafmenu.id}</td>
                                    </tr>
                                  </c:if>
                                </c:forEach>
                                <!-- END 三级菜单  -->
                              
                              </c:if>
                            
                            </c:forEach>
                            <!-- END 二级菜单 -->
                            
                          </tbody>
                        </table>
                      
                      </div>
                    
                    </div>
                  
                  </div>
                
                </c:if>
             </c:forEach>
           </div>
           <!-------END 菜单权限  ------->
         </div>
         
        <div class="form-group ms-form-group" style="margin-top: 0px; margin-bottom: 20px;">
          <div class="col-xs-6 col-xs-offset-3 ms-operation-group top-margin-20 text-center">
            <div class="col-xs-5">
              <button type="button" onclick="window.history.back();" class="btn btn-block btn-default btn-remove">取消</button>
            </div>
            <div class="col-xs-5">
              <button type="submit" class="btn btn-block btn-primary">保存</button>
            </div>
          </div>
        </div>
         
      </form>
       
    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/authority/role-create.js"/>
   <script type="text/javascript">
       require(['page/authority/role-create'], function (page) {
           page.init()
       })
  </script>
  
</body>
</html>